package com.zhongzhi.controller;


import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zhongzhi.service.MeasureService;
import com.zhongzhi.springboot.pojo.Computers;
import com.zhongzhi.springboot.pojo.Measure;
import com.zhongzhi.springboot.pojo.MeasureShow2;
import com.zhongzhi.util.Bo;
import com.zhongzhi.util.JsonResult;
/**
 * 测量业务层
 * @author Administrator
 *
 */
@RestController
@RequestMapping("/measure/")
public class MeasureController {

	@Autowired
	private MeasureService measureService;

	//增加测试数据(业务自动增加)
	@RequestMapping("insert")
	public JsonResult insert(Measure measure) {
		Bo bo = measureService.insert(measure);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//修改测试数据
	@RequestMapping("update")
	public JsonResult update(Measure measure) {
		Bo bo = measureService.update(measure);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}

	//删除业务数据
	@RequestMapping("delete")
	public JsonResult delete(Integer id) {
		Bo bo = measureService.delete(id);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//批量删除数据
	@RequestMapping("deletes")
	public JsonResult deletes(Integer... ids) {
		Bo bo = measureService.deletes(ids);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	
	//根据机型机号删除数据
		@RequestMapping("deletenum")
		public JsonResult deletesnum(String type,String num) {
			Bo bo = measureService.deleteNum(type,num);
			return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
		}

	//查询全部测量数据
	@RequestMapping("select")
	public JsonResult select(Integer pages,Integer line,Long startTime,Long endTime,Integer StationId,String str) {
		Bo bo = measureService.select(pages,line,startTime,endTime,StationId,str);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//查询全部测量数据数量
	@RequestMapping("selectSize")
	public JsonResult selectSize(Long startTime,Long endTime,Integer StationId,String str) {
		//页数,条数,开始时间,结束时间,测试工位id,测试机号
		Bo bo = measureService.selectSize(startTime,endTime,StationId,str);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//查询业务数据(根据id)
	@RequestMapping("selectById")
	public JsonResult selectById(Integer id) {
		Bo bo = measureService.selectById(id);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}

	@RequestMapping("selectByTypeNum")
	public JsonResult selectByTypeNum(Integer typeId,String deviceNum) {
		Bo bo = measureService.selectByTypeNum(typeId,deviceNum);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//8:增加
	@RequestMapping("webinsert")
	public JsonResult webinsert(Measure measure) {
		Bo bo = measureService.webinsert(measure);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//9:修改
	@RequestMapping("webupdate")
	public JsonResult webupdate(Measure measure) {
		Bo bo = measureService.webupdate(measure);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}

	//10:删除
	@RequestMapping("webdelete")
	public JsonResult webdelete(Integer id) {
		Bo bo = measureService.webdelete(id);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//11:查询
	@RequestMapping("webselect")
	public JsonResult webselect() {
		Bo bo = measureService.webselect();
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	//12:根据机型和机号删除数据
	@RequestMapping("webdeletenum")
	public JsonResult webdeleteNum(String type,String num) {
		Bo bo = measureService.webdeletenum(type,num);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
	
	
	//13:命令服务器同步数据
	@RequestMapping("insertShow")
	public JsonResult insertShow(MeasureShow2 measureShow2) {
		JsonResult insertShow = measureService.insertShow(measureShow2);
		return insertShow;
	}
	
	//14:增加数据
	@RequestMapping("webinsertShow")
	public JsonResult webinsertShow(MeasureShow2 measureShow2) {
		Bo bo = measureService.webinsertShow(measureShow2);
		return new JsonResult(bo.getMistake(),bo.getMessage(),bo.getSize(),bo.getObject());
	}
}
